﻿using System;
using BlobNet.Base.Enums;

namespace BlobNet.Base.Storage
{
    [Serializable]
    internal class StorageFactory : IStorageManagerFactory
    {
        #region IStorageManagerFactory Members

        public IStorageManager CreateStorage(StatusStorageType holderType, Guid idEntity, BlobDomain blobDomain)
        {
            IStorageManager result = null;

            switch (holderType)
            {
                case StatusStorageType.Memory:
                    result = new MemoryStorage(idEntity, blobDomain);
                    break;
                case StatusStorageType.Persistent:
                    result = new PersistentStorage(idEntity, blobDomain);
                    break;
                default:
                    throw new ArgumentOutOfRangeException();
            }
            return result;
        }

        #endregion
    }
}